<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns operation mode</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="regexiterator.getflags.html">« RegexIterator::getFlags</a></li>
      <li style="float: right;"><a href="regexiterator.getpregflags.html">RegexIterator::getPregFlags »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.regexiterator.html">RegexIterator</a></li>
    <li>Returns operation mode</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="regexiterator.getmode" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">RegexIterator::getMode</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">RegexIterator::getMode</span> &mdash; <span class="dc-title">Returns operation mode</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-regexiterator.getmode-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>RegexIterator::getMode</strong></span>(): <span class="type">int</span></div>

  <p class="para rdfs-comment">
   Returns the operation mode, see <span class="methodname"><a href="regexiterator.setmode.html" class="methodname">RegexIterator::setMode()</a></span>
   for the list of operation modes.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-regexiterator.getmode-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-regexiterator.getmode-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the operation mode.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-regexiterator.getmode-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="regexiterator.getmode.example.basic">
    <p><strong>示例 #1 <span class="methodname"><strong>RegexIterator::getMode()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$test&nbsp;</span><span style="color: #007700">=&nbsp;array&nbsp;(</span><span style="color: #DD0000">'str1'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'test&nbsp;1'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'teststr2'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'another&nbsp;test'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'str3'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'test&nbsp;123'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$arrayIterator&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ArrayIterator</span><span style="color: #007700">(</span><span style="color: #0000BB">$test</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$regexIterator&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">RegexIterator</span><span style="color: #007700">(</span><span style="color: #0000BB">$arrayIterator</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'/^[a-z]+/'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">RegexIterator</span><span style="color: #007700">::</span><span style="color: #0000BB">GET_MATCH</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$mode&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$regexIterator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getMode</span><span style="color: #007700">();<br />if&nbsp;(</span><span style="color: #0000BB">$mode&nbsp;</span><span style="color: #007700">&amp;&nbsp;</span><span style="color: #0000BB">RegexIterator</span><span style="color: #007700">::</span><span style="color: #0000BB">GET_MATCH</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'Getting&nbsp;the&nbsp;match&nbsp;for&nbsp;each&nbsp;item.'</span><span style="color: #007700">;<br />}&nbsp;elseif&nbsp;(</span><span style="color: #0000BB">$mode&nbsp;</span><span style="color: #007700">&amp;&nbsp;</span><span style="color: #0000BB">RegexIterator</span><span style="color: #007700">::</span><span style="color: #0000BB">ALL_MATCHES</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'Getting&nbsp;all&nbsp;matches&nbsp;for&nbsp;each&nbsp;item.'</span><span style="color: #007700">;<br />}&nbsp;elseif&nbsp;(</span><span style="color: #0000BB">$mode&nbsp;</span><span style="color: #007700">&amp;&nbsp;</span><span style="color: #0000BB">RegexIterator</span><span style="color: #007700">::</span><span style="color: #0000BB">MATCH</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'Getting&nbsp;each&nbsp;item&nbsp;if&nbsp;it&nbsp;matches.'</span><span style="color: #007700">;<br />}&nbsp;elseif&nbsp;(</span><span style="color: #0000BB">$mode&nbsp;</span><span style="color: #007700">&amp;&nbsp;</span><span style="color: #0000BB">RegexIterator</span><span style="color: #007700">::</span><span style="color: #0000BB">SPLIT</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'Getting&nbsp;split&nbsp;pieces&nbsp;of&nbsp;each.'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Getting the match for each item.
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-regexiterator.getmode-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="regexiterator.setmode.html" class="methodname" rel="rdfs-seeAlso">RegexIterator::setMode()</a> - Sets the operation mode</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>